package edu.bu.met683.TravelDroid;

import java.text.DecimalFormat;

import android.content.Context;
import android.graphics.Color;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

public class TourListView extends LinearLayout {
	//private properties	
	private final TextView tourName;
	private final TextView tourLength;
	private final TextView tourDescription;
	
	//constructor
	public TourListView(final Context context, final String name, final double length, final String description, final double proximity) {
		super(context);
		
		this.setOrientation(LinearLayout.VERTICAL);

		LinearLayout.LayoutParams parameters = new LinearLayout.LayoutParams (ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
		
		parameters.setMargins(0, 0, 0, 5);
		DecimalFormat proximityFormat = new DecimalFormat("#0.0");
		
		
		this.tourName = new TextView(context);
		this.tourName.setText(proximityFormat.format(proximity) + "mi from " + name);
		this.tourName.setTextSize(15f);
		this.tourName.setTextColor(Color.WHITE);
		this.tourName.setLayoutParams(parameters);
		this.addView(tourName);

		this.tourLength = new TextView(context);
		this.tourLength.setText("Length: " + Double.toString(length) + "mi");
		this.tourLength.setTextSize(15f);
		this.tourLength.setTextColor(Color.GRAY);
		this.tourLength.setLayoutParams(parameters);
		this.addView(tourLength);
		
		this.tourDescription = new TextView(context);
		this.tourDescription.setText(description);
		this.tourDescription.setTextSize(11f);
		this.tourDescription.setTextColor(Color.GRAY);
		this.tourDescription.setLayoutParams(parameters);
		this.addView(tourDescription);		
	}	
}
